<template>
  <div>
      <breadcrumb></breadcrumb>
      <div>
        <input type="text" v-model="name"><br>
        <input type="text" v-model="age">
      </div>
  </div>
 
 
</template>

<script>
import Vue from 'vue'
export default {
  data(){
    return{
      name:'',
      age:''
    }
  },
  beforeRouteLeave(to,from,next){
    //离开组件守卫
     console.log('---------离组件守卫--------');
     if(this.name==""||this.age==""){
      this.$message.warning('您还没有将表单填写完毕，是否要离开')
     }else{
      next()
     }
  },
  async beforeRouteEnter(to,from,next){
    const result=await Vue.prototype.$api.users.getUserInfoApi()
    if(result.data.auth==1){
        next()
    }else if(result.data.auth==2){
      Vue.prototype.$message.warning('您的权限不够，不能进入')
    }
  }
}
</script>

<style>

</style>